package com.hogocloud.corelibrary.http.interceptor

import okhttp3.Interceptor
import okhttp3.MediaType
import okhttp3.Response
import java.io.IOException

/**
 * Created by dayDream on 2018/5/2.
 */

class CommonParamsInterceptor : Interceptor {

    @Throws(IOException::class)
    override fun intercept(chain: Interceptor.Chain): Response {
        //获取到request
        val request = chain.request()

        //公共参数hasmap
        try {
            val requestBuilder = request.newBuilder()


            val newRequest = requestBuilder.build()
            return chain.proceed(newRequest)
        } catch (e: Exception) {

        }

        return chain.proceed(request)
        //        } else {
        //            showToast("请检查网络");
        //        }
        //        return null;

    }

    companion object {


        val JSON = MediaType.parse("application/json:charset=utf-8")
    }

}
